clc 
close all
clear all
sample_size = 200;
%%PRKS
prks70 = GetThroughputSamples('prks70_throughput_type2.txt',sample_size);
prks80 = GetThroughputSamples('prks80_throughput_type2.txt',sample_size);
prks90 = GetThroughputSamples('prks90_throughput_type2.txt',sample_size);
prks95 = GetThroughputSamples('prks95_throughput_type2.txt',sample_size);


rid70 = GetThroughputSamples('rid70_throughput_type2.txt',sample_size);
rid80 = GetThroughputSamples('rid80_throughput_type2.txt',sample_size);
rid90 = GetThroughputSamples('rid90_throughput_type2.txt',sample_size);
rid95 = GetThroughputSamples('rid95_throughput_type2.txt',sample_size);

scream70 = GetThroughputSamples('scream70_throughput_type2.txt',sample_size);
scream80 = GetThroughputSamples('scream80_throughput_type2.txt',sample_size);
scream90 = GetThroughputSamples('scream90_throughput_type2.txt',sample_size);
scream95 = GetThroughputSamples('scream95_throughput_type2.txt',sample_size);


cmac70 = GetThroughputSamples('cmac70_throughput_type2.txt',sample_size);
cmac80 = GetThroughputSamples('cmac80_throughput_type2.txt',sample_size);
cmac90 = GetThroughputSamples('cmac90_throughput_type2.txt',sample_size);
cmac95 = GetThroughputSamples('cmac95_throughput_type2.txt',sample_size);

csma70 = GetThroughputSamples('csma70_throughput_type2.txt',sample_size);
csma80 = GetThroughputSamples('csma80_throughput_type2.txt',sample_size);
csma90 = GetThroughputSamples('csma90_throughput_type2.txt',sample_size);
csma95 = GetThroughputSamples('csma95_throughput_type2.txt',sample_size);

rtscts70 = GetThroughputSamples('rtscts70_throughput_type2.txt',sample_size);
rtscts80 = GetThroughputSamples('rtscts80_throughput_type2.txt',sample_size);
rtscts90 = GetThroughputSamples('rtscts90_throughput_type2.txt',sample_size);
rtscts95 = GetThroughputSamples('rtscts95_throughput_type2.txt',sample_size);

ALPHA=0.05;

MEAN = zeros(4,6);
Error_MEAN = zeros(4,6);

MEAN(1,1) = mean(prks70);
MEAN(1,2) = mean(csma70);
MEAN(1,3) = mean(rtscts70);
Error_MEAN(1,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(prks70) / sqrt(size(prks70, 1));
Error_MEAN(1,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(csma70) / sqrt(size(csma70, 1));
Error_MEAN(1,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(rtscts70) / sqrt(size(rtscts70, 1));
MEAN(1,6) = mean(scream70);
MEAN(1,4) = mean(rid70);
MEAN(1,5) = mean(cmac70);
Error_MEAN(1,6) =  norminv(1 - ALPHA / 2, 0, 1) * std(scream70) / sqrt(size(scream70, 1));
Error_MEAN(1,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(rid70) / sqrt(size(rid70, 1));
Error_MEAN(1,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(cmac70) / sqrt(size(cmac70, 1));

MEAN(2,1) = mean(prks80);
MEAN(2,2) = mean(csma80);
MEAN(2,3) = mean(rtscts80);
Error_MEAN(2,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(prks80) / sqrt(size(prks80, 1));
Error_MEAN(2,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(csma80) / sqrt(size(csma80, 1));
Error_MEAN(2,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(rtscts80) / sqrt(size(rtscts80, 1));
MEAN(2,6) = mean(scream80);
MEAN(2,4) = mean(rid80);
MEAN(2,5) = mean(cmac80);
Error_MEAN(2,6) =  norminv(1 - ALPHA / 2, 0, 1) * std(scream80) / sqrt(size(scream80, 1));
Error_MEAN(2,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(rid80) / sqrt(size(rid80, 1));
Error_MEAN(2,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(cmac80) / sqrt(size(cmac80, 1));

MEAN(3,1) = mean(prks90);
MEAN(3,2) = mean(csma90);
MEAN(3,3) = mean(rtscts90);
Error_MEAN(3,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(prks90) / sqrt(size(prks90, 1));
Error_MEAN(3,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(csma90) / sqrt(size(csma90, 1));
Error_MEAN(3,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(rtscts90) / sqrt(size(rtscts90, 1));
MEAN(3,6) = mean(scream90);
MEAN(3,4) = mean(rid90);
MEAN(3,5) = mean(cmac90);
Error_MEAN(3,6) =  norminv(1 - ALPHA / 2, 0, 1) * std(scream90) / sqrt(size(scream90, 1));
Error_MEAN(3,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(rid90) / sqrt(size(rid90, 1));
Error_MEAN(3,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(cmac90) / sqrt(size(cmac90, 1));

MEAN(4,1) = mean(prks95);
MEAN(4,2) = mean(csma95);
MEAN(4,3) = mean(rtscts95);
Error_MEAN(4,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(prks95) / sqrt(size(prks95, 1));
Error_MEAN(4,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(csma95) / sqrt(size(csma95, 1));
Error_MEAN(4,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(rtscts95) / sqrt(size(rtscts95, 1));
MEAN(4,6) = mean(scream95);
MEAN(4,4) = mean(rid95);
MEAN(4,5) = mean(cmac95);
Error_MEAN(4,6) =  norminv(1 - ALPHA / 2, 0, 1) * std(scream95) / sqrt(size(scream95, 1));
Error_MEAN(4,4) =  norminv(1 - ALPHA / 2, 0, 1) * std(rid95) / sqrt(size(rid95, 1));
Error_MEAN(4,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(cmac95) / sqrt(size(cmac95, 1));

figure;
handle = barweb(MEAN, Error_MEAN,1, ['70%';'80%';'90%';'95%'], [], ['PDR requirement'], ['Mean throughput (packets/slot)'], jet);
handle.legend =legend ('PRKS','CSMA','RTS-CTS','RIDB','CMAC','SCREAM','orientation','horizontal');
set(gca,'fontsize',36);
box on
maximize ();
